Page({
  data: {
    bgd169: "",
    bgd170: "",
    bgd171: "",
    bgd172: "",
    bgd173: "",
    bgd174: "",
    bgd175: "",
    bgd176: "",
    bgd177: "",
    bgd178: "",
    bgd179: "",
    bgd180: "",
    bgd181: "",
    bgd182: "",
    bgd183: "",
    bgd184: "",
    bgd185: "",
    bgd186: "",
    bgd187: "",
    bgd188: "",
    bgd189: "",
    bgd190: "",
    bgd191: "",
    bgd192: "",
    bgd193: "",
    bgd194: "",
    bgd195: "",
    bgd196: "", 
  },
  onLoad: function () {
    console.log("order进来");
    //wx.clearStorage();
    var that = this;
    wx.request({
      url: 'https://www.szz5.com/admin/selectAll',
      method: 'POST',
      data: {},
      success: function (res) {
        console.info("++++++++++=1", JSON.stringify(res));
        var list = res.data;
        console.info("++++++++++=2", JSON.stringify(list));
        if (list != null) {
          for (var index in list) {
            console.info("++++++++++=3", list[index]);
            var bathid = list[index];
            if (bathid == '169') {
              console.info("进来001");
              that.setData({
                bgd169: "red"
              });
            }
            if (bathid == "170") {
              console.info("进来002");
              that.setData({
                bgd170: "red"
              });
            }
            if (bathid == "171") {
              that.setData({
                bgd171: "red"
              });
            }
            if (bathid == "172") {
              that.setData({
                bgd172: "red"
              });
            }
            if (bathid == "173") {
              that.setData({
                bgd173: "red"
              });
            }
            if (bathid == "174") {
              that.setData({
                bgd174: "red"
              });
            }
            if (bathid == "175") {
              that.setData({
                bgd175: "red"
              });
            }
            if (bathid == "176") {
              that.setData({
                bgd176: "red"
              });
            }
            if (bathid == "177") {
              that.setData({
                bgd177: "red"
              });
            }
            if (bathid == "178") {
              that.setData({
                bgd178: "red"
              });
            }
            if (bathid == "179") {
              that.setData({
                bgd179: "red"
              });
            }
            if (bathid == "180") {
              that.setData({
                bgd180: "red"
              });
            }
            if (bathid == "181") {
              that.setData({
                bgd181: "red"
              });
            }
            if (bathid == "182") {
              that.setData({
                bgd182: "red"
              });
            }
            if (bathid == "183") {
              that.setData({
                bgd183: "red"
              });
            }
            if (bathid == "184") {
              that.setData({
                bgd184: "red"
              });
            }
            if (bathid == "185") {
              that.setData({
                bgd185: "red"
              });
            }
            if (bathid == "186") {
              that.setData({
                bgd186: "red"
              });
            }
            if (bathid == "187") {
              that.setData({
                bgd187: "red"
              });
            }
            if (bathid == "188") {
              that.setData({
                bgd188: "red"
              });
            }
            if (bathid == "189") {
              that.setData({
                bgd189: "red"
              });
            }
            if (bathid == "190") {
              that.setData({
                bgd190: "red"
              });
            }
            if (bathid == "191") {
              that.setData({
                bgd191: "red"
              });
            }
            if (bathid == "192") {
              that.setData({
                bgd192: "red"
              });
            }
            if (bathid == "193") {
              that.setData({
                bgd193: "red"
              });
            }
            if (bathid == "194") {
              that.setData({
                bgd194: "red"
              });
            }
            if (bathid == "195") {
              that.setData({
                bgd195: "red"
              });
            }
            if (bathid == "196") {
              that.setData({
                bgd196: "red"
              });
            }
          }

          // wx.showToast({
          //   title: '获取数据失败',      
          //   duration: 1500      
          // })
        }
      }
    })
  },
  gotoresult: function (e) {
    var ID = e.currentTarget.id;
    console.log("idd", ID);
    // wx.clearStorage("userInfo");
    var stor = wx.getStorageSync("userInfo");
    var getkey = wx.getStorageSync("key1");
    if (stor == null || stor == "") {
      console.log("stor" + stor);
      wx.showModal({
        title: '提示',
        content: '您没有激活状态，请去激活',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');

            wx.hideToast()
            wx.switchTab({
              url: '../../login/login'
            })

            console.log('1');
            // return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })
    } else if (getkey) {
      wx.showModal({
        title: '提示',
        content: '您已经选择过！',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    } else {

      wx.request({
        url: 'https://www.szz5.com/admin/byBathId',
        method: 'POST',
        data: { bathId: ID },
        success: function (res) {
          console.info("++++++++++=4", JSON.stringify(res));
          if (res.data == '1') {
            wx.showModal({
              title: '提示',
              content: '此澡位已被预订！',
              success: function (res) {
                if (res.confirm) {
                  console.log('用户点击确定');
                  return;
                } else if (res.cancel) {
                  console.log('用户点击取消');
                  return;
                }
              }
            })
          }
        }

      })
      wx.showModal({
        title: '提示',
        content: '是否预定该位置',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            wx.setStorageSync("keykey", ID);
            wx.navigateTo({
              url: '../../seltime/seltime',
            })
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    }
    // wx.getStorage({
    //   key: 'key',
    //   success: function (res) {
    //     console.log(res.data);
    //     if(res){
    //       console.log(res);

    //       return;
    //     }
    //   },
    // });



  }



})